package com.tuanzi.loan.web.bean.product.prefilter;

import com.tuanzi.loan.business.service.product.prefilter.LoanProductPrefilterService;
import com.tuanzi.loan.core.aspect.Debug;
import com.tuanzi.loan.vo.request.product.prefilter.LoanProductPrefilterSearchRequest;
import com.tuanzi.loan.vo.response.product.prefilter.LoanProductPrefilterSearchResponse;
import com.tuanzi.loan.web.configuration.JSFListingSessionBean;
import com.tuanzi.loan.web.lazy.prefilter.LoanProductPrefilterLazyDataModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.faces.bean.ViewScoped;

/**
 * @author Ray 2017/09/21
 */
@Data
@Debug
@Component
@ViewScoped
@EqualsAndHashCode(callSuper = true)
public class LoanProductPrefilterListBean extends JSFListingSessionBean<LoanProductPrefilterSearchRequest, LoanProductPrefilterSearchResponse> {

	@Autowired
	private LoanProductPrefilterService productPrefilterService;

	public void onReset() {
		initLazyDataModel();
	}

	public String onAdd() {
		return redirect("/views/product/prefilter/info.xhtml");
	}

	public String onEdit(String id) {
		return redirect("/views/product/prefilter/info.xhtml?id=" + id);
	}

	@Override
	protected String page() {
		return "/views/product/prefilter/list.xhtml";
	}

	@Override
	protected void initLazyDataModel() {
		$ = new LoanProductPrefilterSearchRequest();
		lazyDataModel = new LoanProductPrefilterLazyDataModel($, session, productPrefilterService);
	}
}
